<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/plan/css/add.css"/>
    <script type="text/javascript" src="/plan/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/plan/js/layer.js" ></script>
        	<script type="text/javascript" src="/plan/js/mobileSelect.js"></script>
	<link rel="stylesheet" type="text/css" href="/plan/css/mobileSelect.css"/>
    <script type="text/javascript" src="/plan/js/rem.js" ></script>

    <title>新增计划</title>
</head>
<body>
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" >
<ul class="order_money">
      <li>
		<span class="week">开会周次</span><span style="color: #f83535;">*</span>
		<div id="trigger4" class="trigger4" style="display: inline-block;width: 80%;margin-top: 0.1rem;  text-align: right;  float: right;">
		 	请选择
		</div>
		 <input type="hidden" name="row[year]" id="year" value="" />								
		 <input type="hidden" name="row[week]" id="week" value="" />								
	</li>
	    <li>
    		<span class="changci">开会场次</span>
    		<span style="color: #f83535;">*</span>
    		<select class="session" name="row[season]">
    			<option value="0">请选择</option>
    			<?php for($ad = 1;$ad<=14;$ad++ ){ ?>
    			<option value="{$ad}">{$ad}场</option>
    			<?php }?>
    		</select>
    </li>
    <li>
    		<span class="changdi">开会场地</span>
    		<span style="color: #f83535;float: left;margin-left: 0.1rem;">*</span>
    		<input class="address" type="text" name="row[address]"  placeholder="请输入开会场地" />
    </li>
</ul>
<ul class="beizhu">
	<li>
		<p class="title">备注<span style="color: #f83535;">*</span></p>
        <textarea name="row[desc]" value="" placeholder="请输入备注信息" ></textarea>
    </li>
</ul>
<div class="button">
	<input id="status" name="row[status]" value="0" type="hidden">
		<a href="#"><div class="close" onclick="tj(0)">保存草稿</div></a>
		<div class="continue"><input class="pay" type="button" onclick="tj(1)"  value="提交审批" /></div>
</div>

</form>
<script>
var arr = [];
	var DefaultsDate = 1;
	var DefaultsDateW = {$DefaultsDateW};
  	$.ajax({
	  url: '/api/ajax/years',
	  type: 'post',
	  async: false,
	  success: function (year) {
	  	console.log(year);
	  	   arr = year.data;
	  	 
	  		/*$.each(year.data,function (index,value) {
	  			 arr[index] = value;
	  			$.get('https://oa.fc62.com/api/ajax/year?year='+value.value,function (week) {
						arr[index]['childs'] = week.data;
					});

		   });*/
	  }
	});
	//周次联动
	var mobileSelect4 = new MobileSelect({
	    trigger: '#trigger4',
	    title: '周次选择',
	    wheels: [{data:arr}],
	    position:[DefaultsDate,DefaultsDateW],
		 transitionEnd:function(indexArr, data){
		        
		 },
		 callback:function(indexArr, data){
		    $('#week').val(data[1].id);
		    $('#year').val(data[0].id);
		    $('.week').css('font-size','0.2rem');
		 }
	});

</script>
<script>
 //同意 驳回
function tj(val) {
  $('#submit_to_save').val(val);
  var year = $('#year').val();
  var week = $('#week').val();
	var session = $('.session').val();
	var address = $('.address').val();
	var txt = $('textarea').val();
	if(week == 0){
			layer.open({
			content:'请选择开会周次' ,
			skin: 'msg',
			time: 2 //2秒后自动关闭
		});
		return false
	}
	if(session == 0){
			layer.open({
			content:'请选择开会场次' ,
			skin: 'msg',
			time: 2 //2秒后自动关闭
		});
		return false
	}
	if(address == ''||address == null){
			layer.open({
			content:'请输入开会场次' ,
			skin: 'msg',
			time: 2 //2秒后自动关闭
		});
		return false
	}
	if(txt == ''||txt == null){
			layer.open({
			content:'请输入备注' ,
			skin: 'msg',
			time: 2 //2秒后自动关闭
		});
		return false
	}
	var indexx = layer.open({type: 2});
	$.ajax({
	  type: 'post',
	  url:"/index/plan/add" ,
	  data:{year:year,week:week,season:session,address:address,desc:txt,status:val},
	  dataType: "json",
	  success: function(data){
	  	console.log(data);
	  	if(data.code){
	  		 layer.open({
				content:'操作成功' ,
				skin: 'msg',
				time: 2 //2秒后自动关闭
			});
	  		 setTimeout(function () {
				window.location.href = "/index/plan/lists";
			},2000);
	  	}else{
	  		layer.close(indexx);
	  		  //询问框
			  layer.open({
			    content: data.msg
			    ,btn: ['确定', '不要']
			    ,yes: function(index){
			      layer.close(index);
			      window.location.href = "/index/plan/view/ids/"+data.data;
			    }
			  	,no:function(index){
			  		layer.close(index);
			  	}
			  });
	  	}
	  
	    //window.location.href = "";
	   }
	});
  //$('#add-form').submit();
}
$(function(){
	//字体变化
	$('#week').change(function(){
		var week = $('#week').val();
		if(week != 0){
			$('.zhou').css('font-size','0.2rem');
		}else{
			$('.zhou').css('font-size','0.28rem');
		}
	});
	$('.queding').click(function(){
		var week = $('#week').val();
		if(week != ''){
			$('.zhou').css('font-size','0.2rem');
		}else{
			$('.zhou').css('font-size','0.28rem');
		}
	});
	$('.session').change(function(){
		var session = $('.session').val();
		if(session != 0){
			$('.changci').css('font-size','0.2rem');
		}else{
			$('.changci').css('font-size','0.28rem');
		}
	});
	$('.address').keyup(function(){
		var address = $('.address').val();
		if(address != ''){
			$('.changdi').css('font-size','0.2rem');
		}else{
			$('.changdi').css('font-size','0.28rem');
		}
	});
	$('textarea').keyup(function(){
		var textarea = $('textarea').val();
		if(textarea != ''){
			$('.title').css('font-size','0.2rem');
		}else{
			$('.title').css('font-size','0.28rem');
		}
	});
});
	  
</script>

</body>
</html>
